'''
@Project ：my_python_project 
@File    ：propety_test1.py
@IDE     ：PyCharm 
@Author  ：xionglinhui
@Date    ：2024/10/22 上午7:44 
'''
class Foo:
    def __init__(self, val):
        self.__NAME = val

    def get_name(self):
        return self.__NAME


    def set_name(self, value):
        if not isinstance(value, str):
            raise TypeError('%s must be str' %value)
        self.__NAME = value

    def del_name(self):
        # raise PermissionError('Can not delete')
        print('不让删除')

    name = property(get_name,set_name,del_name)
    # 说明1： name = property(get_name） ==>等价于

f = Foo('lucy')
print(f.name)
f.name = 'jack'
print(f.name)